object ClubManagementSystem {
  def main(args: Array[String]): Unit = {
    // 1. 存储社团信息
    val clubData = Map(
      "篮球社" -> (42, 2010, "体育"),
      "编程社" -> (35, 2015, "技术"),
      "足球社" -> (38, 2008, "体育"),
      "文学社" -> (28, 2012, "文化"),
      "摄影社" -> (22, 2018, "艺术")
    )

    // 2. 筛选体育类社团（修复变量解析错误）
    val sportsClubs = clubData.filter { case (_, (_, _, typ)) =>
      typ == "体育"
    }
    println("体育类社团:")
    sportsClubs.foreach { case (name, (count, _, _)) =>
      println(s"$name - ${count}人")  // 用${count}明确变量边界
    }

    // 3. 计算平均成员数
    val totalMembers = clubData.values.map(_._1).sum
    val avgMembers = totalMembers.toDouble / clubData.size
    println(f"\n平均成员数：$avgMembers%.1f人")

    // 4. 找出成立最早的社团
    val oldestClub = clubData.minBy { case (_, (_, year, _)) => year }
    println(s"\n成立最早的社团：${oldestClub._1} (${oldestClub._2._2}年)")
  }
}